package com.shop.service;

import java.util.List;

import com.shop.entity.Product;
import com.shop.cart.Cart;
import com.shop.dao.ProductDaoImpl;

public class ProductService {
	private ProductDaoImpl ProductDao = new ProductDaoImpl();

	public List<Product> getProductsByWord(String searchKeyWord) {
		return ProductDao.getProductsByWord(searchKeyWord);
	}
	//获取 产品页
	public List<Product> getAllProduct() {
		return ProductDao.getAllProduct();
	}
	
	public void addProduct(Product product) {
		ProductDao.addProduct(product);
	}
	
	public void deleteProduct(int id) {
        ProductDao.deleteProduct(id);
    }
	
	public boolean isExist(Product product) {
        return ProductDao.isExist(product);
    }
	
	public boolean updateProduct(Product product) {
        return ProductDao.updateProduct(product);
    }

	public Product findProductById(int id) {
		Product p = ProductDao.findProductById(id);
		return p;
	}

	// 删除购物车中购物项
	public void deleteCartItem(int id, Cart cart) {
		cart.getMap().remove(id);
	}

	// 清空购物车
	public void clearCart(Cart cart) {
		cart.getMap().clear();
	}
	

}
